//引入路由对象
import { createRouter, createWebHistory, createWebHashHistory, createMemoryHistory, RouteRecordRaw } from 'vue-router'

//vue2 mode history vue3 createWebHistory
//vue2 mode  hash  vue3  createWebHashHistory
//vue2 mode abstact vue3  createMemoryHistory

//路由数组的类型 RouteRecordRaw
// 定义一些路由
// 每个路由都需要映射到一个组件。
const routes: Array<RouteRecordRaw> = [{
  path: '/',
  component: () => import('../components/login.vue')
}, {
  path: '/home',
  name: 'home',
  component: () => (import('../home/index.vue'))
},
{
  path: '/news/:name',
  name: 'news',
  meta: {
    title: 'news'
  },
  component: () => (import('../news/index.vue'))
}]



const router = createRouter({
  history: createWebHistory(),
  routes
})

//导出router
export default router